using System.Data;
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

namespace Microsoft.EntityFrameworkCore.Dm.Storage.Internal;

public class DmFloatTypeMapping : FloatTypeMapping
{
	public DmFloatTypeMapping([NotNull] string storeType, DbType? dbType = null)
		: base(storeType, dbType)
	{
	}

	protected DmFloatTypeMapping(RelationalTypeMappingParameters parameters)
		: base(parameters)
	{
	}//IL_0001: Unknown result type (might be due to invalid IL or missing references)


	public override RelationalTypeMapping Clone(string storeType, int? size)
	{
		return new DmFloatTypeMapping(this.Parameters.WithStoreTypeAndSize(storeType, size, null));
	}

	public override CoreTypeMapping Clone(ValueConverter converter)
	{
		return new DmFloatTypeMapping(this.Parameters.WithComposedConverter(converter));
	}

	protected override string GenerateNonNullSqlLiteral(object value)
	{
		DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(0xA, 2);
		defaultInterpolatedStringHandler.AppendLiteral("CAST(");
		defaultInterpolatedStringHandler.AppendFormatted(base.GenerateNonNullSqlLiteral(value));
		defaultInterpolatedStringHandler.AppendLiteral(" AS ");
		defaultInterpolatedStringHandler.AppendFormatted(this.StoreType);
		defaultInterpolatedStringHandler.AppendLiteral(")");
		return defaultInterpolatedStringHandler.ToStringAndClear();
	}
}
